import request from '@/utils/request'

// 管理员库存管理API
export const adminInventoryApi = {
  // 分页查询管理员库存记录
  getRecordsPage(params) {
    return request({
      url: '/admin/inventory/records/page',
      method: 'get',
      params
    })
  },

  // 根据商品ID查询库存记录
  getRecordsByProductId(productId) {
    return request({
      url: `/admin/inventory/records/product/${productId}`,
      method: 'get'
    })
  },

  // 查询入库记录（新增商品）
  getInRecordsPage(params) {
    return request({
      url: '/admin/inventory/in-records/page',
      method: 'get',
      params
    })
  },

  // 查询出库记录（分配给商家）
  getOutRecordsPage(params) {
    return request({
      url: '/admin/inventory/out-records/page',
      method: 'get',
      params
    })
  },

  // 创建商品入库记录
  createProductInRecord(data) {
    return request({
      url: '/admin/inventory/records/in',
      method: 'post',
      data
    })
  },

  // 创建商品分配出库记录
  createAllocateOutRecord(data) {
    return request({
      url: '/admin/inventory/records/allocate',
      method: 'post',
      data
    })
  },

  // 库存调整记录
  createAdjustRecord(data) {
    return request({
      url: '/admin/inventory/records/adjust',
      method: 'post',
      data
    })
  },

  // 导出库存记录
  exportRecords(params) {
    return request({
      url: '/admin/inventory/records/export',
      method: 'get',
      params,
      responseType: 'blob'
    })
  },

  // 获取库存统计信息
  getInventoryStatistics(params) {
    return request({
      url: '/admin/inventory/statistics',
      method: 'get',
      params
    })
  }
}

export default adminInventoryApi 